package IO.g3;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;

public class Serialisierung {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
		
		Student s = new Student("Horst", 123, "Informatik");
		Date date = new Date();
		
		ObjectOutputStream out = 
				new ObjectOutputStream(new FileOutputStream("x.dat"));
		
		out.writeObject(date);
		out.writeObject(s);
		
		ObjectInputStream in = 
				new ObjectInputStream(new FileInputStream("x.dat"));
		
		Date d = (Date)in.readObject();
		Student s2 = (Student)in.readObject();
		
		System.out.println(date);
		System.out.println(s2.getName());
		
		

	}

}
